<script>
export default {
  name: 'sellerPage',
  data() {
    return {
      accountBalance: 0,
      ruleForm: {
        // 交易类型:
        tradeType: '',
        // 充值方式:
        rechargeType: '',
        // 交易状态
        tradeStatus: ''
      },
      tableData: [],
      // 分页数据
      currentPage: 1,
      pageSize: 10,
      total: 0,
      dialogVisible: false,
      form: {
        rechargeAmount: '',
        rechargeType: ''
      }
    }
  },
  created() {
    // 获取路由参数
    this.amount = this.$route.query.amount
  },
  methods: {
    handleReset() {
      this.$refs.ruleForm.resetFields()
    },
    handleSizeChange(val) {
      this.pageSize = val
      this.getTableData()
    },
    handleCurrentChange(val) {
      this.currentPage = val
      this.getTableData()
    },
    // TODO 获取表格数据
    getTableData() {}
  }
}
</script>

<template>
  <div class="sellerPage">
    <div class="title">
      <p>
        广告币：￥<span style="color: #eb6009">￥{{ accountBalance }}</span>
        <el-button
          @click="dialogVisible = true"
          style="background-color: #eb6009; margin-left: 60px; color: #fff"
        >充值
        </el-button>
        <el-button type="text" style="color: #818181"
        >(一元人民币等于1个广告币)
        </el-button>
        <el-button type="text" style="color: #ff0000; margin-left: 40px">
          注：30分钟未支付的订单，系统自动取消！
        </el-button>
      </p>
    </div>
    <!-- /.title -->
    <div class="form">
      <el-form
        :model="ruleForm"
        ref="ruleForm"
        label-width="100px"
        :inline="true"
      >
        <el-form-item label="交易类型">
          <el-select
            style="width: 300px"
            v-model="ruleForm.tradeType"
            placeholder="请选择交易类型"
            clearable
          >
            <el-option label="充值" value="1"></el-option>
            <el-option label="消费" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="充值方式">
          <el-select
            style="width: 300px"
            v-model="ruleForm.rechargeType"
            placeholder="请选择充值方式"
            clearable
          >
            <el-option label="支付宝" value="1"></el-option>
            <el-option label="微信" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="交易状态">
          <el-select
            style="width: 300px"
            v-model="ruleForm.tradeStatus"
            placeholder="请选择交易状态"
            clearable
          >
            <el-option label="已取消" value="1"></el-option>
            <el-option label="已完成" value="2"></el-option>
            <el-option label="待处理" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary">搜索</el-button>
          <el-button @click="handleReset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- /.form -->
    <div class="bus">
      <p style="margin-left: 20px; font-size: 14px">
        当前表格已选择 0 项
        <el-button
          style="background-color: #feeee6; border: none; color: #eb6009"
        >清空
        </el-button>
      </p>
    </div>
    <!-- /.bus -->
    <div class="table">
      <el-table :data="tableData" style="width: 100%">
        <!-- 创建时间、交易类型、充值金额、消费金额、交易描述、充值方式、广告币余额、交易状态、数据来源 -->
        <el-table-column prop="createTime" label="创建时间"></el-table-column>
        <el-table-column prop="tradeType" label="交易类型"></el-table-column>
        <el-table-column prop="rechargeAmount" label="充值金额">
        </el-table-column>
        <el-table-column prop="consumeAmount" label="消费金额">
        </el-table-column>
        <el-table-column prop="tradeDesc" label="交易描述"></el-table-column>
        <el-table-column prop="rechargeType" label="充值方式">
        </el-table-column>
        <el-table-column prop="accountBalance" label="广告币余额">
        </el-table-column>
        <el-table-column prop="tradeStatus" label="交易状态"></el-table-column>
        <el-table-column prop="dataSource" label="数据来源"></el-table-column>
        <el-table-column prop="action" label="操作">
          <template slot-scope="scope">
            <el-button type="text" size="small">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- /.table -->
    <el-row type="flex" justify="end" style="margin-top: 20px">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </el-row>
    <!-- 弹窗 -->
    <el-dialog title="充值" :visible.sync="dialogVisible">
      <el-form :model="form" ref="ruleForm">
        <el-form-item label="充值金额">
          <el-input
            placeholder="请输入充值金额"
            style="width: 500px"
            v-model="form.rechargeAmount"
          ></el-input>
        </el-form-item>
        <el-form-item label="充值方式">
          <el-button
            @click="form.rechargeType = '微信'"
            :style="
              form.rechargeType === '微信'
                ? 'background-color: #eb6009; color: #fff'
                : ''
            "
          >微信
          </el-button>
          <el-button
            @click="form.rechargeType = '支付宝'"
            :style="
              form.rechargeType === '支付宝'
                ? 'background-color: #eb6009; color: #fff'
                : ''
            "
          >支付宝
          </el-button>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button
          style="background-color: #eb6009; color: #fff"
          @click="dialogVisible = false"
        >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<style scoped lang="scss">
.sellerPage {
  width: 98%;
  min-height: 750px;
  margin-top: 1%;
  margin-bottom: 1%;
  margin-left: 1%;
  background-color: #fff;
  overflow: hidden;
  padding: 0 20px;

  .form {
    margin-top: 20px;
  }

  .bus {
    margin-top: 40px;
    background-color: #feeee6;
    color: #eb6009;
  }

  .table {
  }
}
</style>
